package com.huashi.dealer.modular.business.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huashi.dealer.commonEntity.Order;
import com.huashi.dealer.commonEntity.OrderAddress;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * 订单Mapper接口
 */
@Mapper
@Component("apiOrderMapper")
public interface OrderMapper extends BaseMapper<Order> {
    OrderAddress getOrderAddress(Long orderId);

    // Dashboard：最新订单
    List<Order> selectLatestOrders(@Param("list") List<Long> visibleUserIds,
                                   @Param("start") LocalDate start,
                                   @Param("end") LocalDate end,
                                   @Param("limit") Integer limit);

    // Dashboard：订单实付合计
    BigDecimal sumOrderPayPrice(@Param("list") List<Long> visibleUserIds,
                                @Param("start") LocalDate start,
                                @Param("end") LocalDate end);

    // Dashboard：待审核订单数量
    Integer countAuditOrders(@Param("list") List<Long> visibleUserIds,
                             @Param("start") LocalDate start,
                             @Param("end") LocalDate end);

    // Dashboard：待发货订单数量
    Integer countDeliveryOrders(@Param("list") List<Long> visibleUserIds,
                                @Param("start") LocalDate start,
                                @Param("end") LocalDate end);
}